<?php

namespace app\controller\admin;

use app\BaseController;
use app\model\Account;
use think\response\Json;

class StoreAccount extends BaseController
{
    public function lst(): Json
    {
        return $this->success($this->app->make(Account::class)->getPage());
    }

    public function save(): Json
    {
        if (!$this->request->isPost()) throw new \Exception("请求方式错误", 7001);
        return $this->success($this->app->make(Account::class)->updateOrAdd());
    }

    public function changeState(): Json
    {
        if (!$this->request->isPost()) throw new \Exception("请求方式错误", 7001);
        return $this->success($this->app->make(Account::class)->changeState());
    }

    public function delete()
    {
        if(!$this->request->isDelete()) throw new \Exception("请求方式错误", 7001);
        return $this->success($this->app->make(Account::class)->deleteAccount());
    }
}
